<?php require_once(dirname(__FILE__).'/inc/config.inc.php');IsModelPriv('goodsorder'); 
require_once "function.php";
$id=htmlspecialchars($id);



/*
进度：
0 已经撤单
1 报修成功
2 客服已经联系
3 系统已经派单
4 工程师接单
5 维修完成
6 已经评价
*/

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>任务详情</title>
<link href="templates/style/admin.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="templates/js/jquery.min.js"></script>
<script type="text/javascript" src="layer/layer.js"></script>
<!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
<link rel="stylesheet" href="ui/css/bootstrap.min.css">
<link rel="stylesheet" href="ui/css/bootstrap-theme.min.css" >
<link rel="stylesheet" href="templates/js/zoomify.min.css">


</head>

<body style="width:890px;">
<?php

$sql= "SELECT f.*,t.dataname as typename,j.dataname as jinduname,d.dataname as devicename,u.truename as truename ,u.headimgurl as headimgurl,u.school as school,u.address as address,u.mobile as mobile FROM `#@__order` as f
		left join `#@__user`  as u on u.id=f.uid
		left join `#@__cascadedata`  as t on t.datavalue=f.apply_type  
		left join `#@__cascadedata`  as d on d.datavalue=f.apply_device
		left join `#@__cascadedata`  as j on j.datavalue=f.jindu  
		WHERE t.datagroup='type'  AND j.datagroup='jindu'  AND d.datagroup='device'    AND    f.id='$id' ";


 $row = $dosql->GetOne($sql);

  $odernum=date("Ymd",$row['post_time'])."-".$row['id'];

  //故障图片
  $picurl_arr=explode(',',$row['picfiles']);
  $pic_lists="";
  array_pop($picurl_arr);
  for($i=0;$i<count($picurl_arr);$i++){
	  $pic_lists.='<li class="example"><img src="'.$picurl_arr[$i].'" width=120/></li>';
  }
  
  //完修图片
  $over_picurl_arr=explode(',',$row['over_picurls']);
  $over_pic_lists="";
  array_pop($over_picurl_arr);
  for($i=0;$i<count($over_picurl_arr);$i++){
	  $over_pic_lists.='<li class="example"><img src="'.$over_picurl_arr[$i].'" width=120/></li>';
  }

  $jindu=intval($row['jindu']);

?>
<h1 class="tit">任务详情</h1>
<div class="order_top"><div class="order_top1">单号：<?php echo $odernum;?></div><div class="order_top1 t_fr">创建日期：<?php echo date("Y年m月d日",$row['post_time']);?></div></div>
<table width="200" border="1"  class="table table-bordered">
  <tr>
    <td>单位：</td>
    <td><?php echo $row['school'];?></td>
    <td>联系人：</td>
    <td><?php echo $row['truename']."    ".$row['mobile'];?> </td>
  </tr>
  <tr>
    <td>地址：</td>
    <td> <?php echo $row['address']?></td>
    <td>位置信息：</td>
    <td><?php echo $row['latitude'].",".$row['longitude']?></td>
  </tr>
  <tr>
    <td>服务类型</td>
    <td><?php echo $row['typename'];?></td>
    <td>设备类型：</td>
    <td><?php echo $row['devicename']?></td>
  </tr>
  <tr>
    <td>任务详情：</td>
    <td colspan="3" ><?php echo $row['content']?></td>
  </tr>
    <tr>
    <td>故障图片：</td>
    <td colspan="3" ><ul class="photo_list"><?php echo $pic_lists?></ul></td>
  </tr>
    <tr>
    <td>任务进度：</td>
    <td colspan="3" >
    <ul >
    <?php
		$dosql->Execute("SELECT * FROM `#@__order_log` WHERE orderid='$id'  ORDER BY id asc");
			while($row2 = $dosql->GetArray())
			{
			?>
			<li><i class="glyphicon glyphicon-ok-sign"><?php echo $row2['op']?></i> <?php echo date("Y-m-d H:i:s",$row2['op_time'])?> <span class="red">   <?php echo getManage($row2['manageid'])?></span></li>
			<?php
			}
    ?>
    </ul>
    </td>
  </tr> 
  <?php 
	if($jindu>1){
	?>
    <tr>
    <td>客服联系备注：</td>
    <td colspan="3" ><?php echo $row['remark']?><br />操作时间：<?php echo date("Y-m-d H:i:s",$row['remark_time'])?></td>
  </tr> 
    <?php }?>

  <?php 
	if($jindu>'4'){
	?>
    <tr>
    <td>维修费用：</td>
    <td colspan="3" ><?php echo $row['fee']?></td>
  </tr>
    <tr>
    <td>维修概要：</td>
    <td colspan="3" ><?php echo $row['over_remark']?><br />操作时间：<?php echo date("Y-m-d H:i:s",$row['over_time'])?><br />位置信息:<?php echo $row['latitude2'].",".$row['longitude2']?></td>
  </tr> 
    <tr>
    <td>完修图片<? echo $jindu?>：</td>
    <td colspan="3" ><ul class="photo_list"><?php echo $over_pic_lists?></ul></td>
  </tr>
  <?php }
  if($jindu==6){
	  					// 评价
					$pingjia_start="";
					$pingjia_remark="";
					$start_str="";
					if($jindu==6){
						$p=$dosql->GetOne("SELECT * FROM `#@__order_evaluate` WHERE orderid='$id' ");
						if(is_array($p) && isset($p['id']) ){
							$pingjia_start=$p['start'];
							$pingjia_remark=$p['remark'];
							for($i=0;$i<$pingjia_start;$i++){
								$start_str.='<img src="img/x2.png">';
							}
						}
					}
	  ?>
          <tr>
    <td>服务评价星级：</td>
    <td colspan="3" ><?php echo $start_str?></td>
  </tr> 
    <tr>
    <td>服务评价内容：</td>
    <td colspan="3" ><div style=" width:650px;"><?php echo $pingjia_remark?></div></td>
  </tr> 
  <?php
  }
	  ?>
</table>

<?php 
if($jindu<5){
?>
<div class="lianxi_box">
中止备注：
<textarea name="remark" id="remark" class="form-control w500"></textarea>
<button type="button" class="btn btn-danger" onclick="zhongzhi('<?php echo $id;?>')">确定中止</button>
</div>
<?php 
}else{
	echo "已经完成的不能中止";
}
?>

<script>
  function zhongzhi(id){
	  var _remark=$("#remark").val();
	  $.ajax({
		  type: 'POST',
		  url: "op.php",
		  data: {id:id,op:'zhongzhi',remark:_remark},
		  dataType: 'JSON',
		  success:function(result){
		  console.log(result);
			if(result.errno==0){
				 console.log(result.msg);
				if(result.msg==="ok"){
						$(".lianxi_box").hide();
						layer.msg('操作成功');
						window.location.reload();
					
				}else{
					 layer.msg('操作失败');
				}
			}
		  }
	  });
	  
  }
  

  
</script>
<script src="templates/js/zoomify.min.js"></script>

<script type="text/javascript">
	$('.example img').zoomify();
</script>
</body>
</html>